﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AspNetCs.Model;
using AspNetCs.Bll;
using System.Data;
using System.Collections;
using AspNetCs.Enumerations;
using AspNetCs.Enumerations.memorial_enum;
using AspNetCs.Enumerations.User_Enum;
using AspNetCs.Common;
using AspNetCs.Enumerations.Channel_Enum;

public partial class Users_HappyPetList : BasePage
{
    private HapppNetBLL bll = new HapppNetBLL();
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckUserExit("Login.Aspx?ReUrl=" + configInfo.InstallDir + "Users/HappyPetList.aspx", "请您登录", true);
        if (!IsPostBack)
        {
            getMyCreateHappyPets();
        }
    }

    private void getMyCreateHappyPets()
    {
        Users_Model userModel = Base_GetUserInfo;
        string propertyItems = " * ";
        DataTable dataTable = bll.getMyCreateHappyPet( propertyItems,userModel.UserId);
        rptHappyPets.DataSource = dataTable;
        rptHappyPets.DataBind();
    }

    private bool deleteNetMu(int id)
    {
        int count = 0;
        count = bll.DeleteHappyPet(id);
        return count > 0 ? true : false;
    }

    protected void rptHappyPets_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        bool bo = false;
        if (e.CommandName == "delete")
        {
            Button btnDelete = e.Item.FindControl("btnDelete") as Button;
            if (btnDelete != null)
            {
                string id = btnDelete.CommandArgument;
                try
                {
                    bo = deleteNetMu(Convert.ToInt32(id));
                }
                catch (Exception ex)
                {
                    bo = false;
                }
            }
        }
        else if (e.CommandName == "Update")
        {
            Button btnUpdate = e.Item.FindControl("btnUpdate") as Button;
            if (btnUpdate != null)
            {
                string id = btnUpdate.CommandArgument;
                try
                {
                    Response.Redirect("UpdateHappyPet_" + Convert.ToInt32(id) + ".aspx");
                }
                catch (Exception ex)
                {
                }
            }
        }

        getMyCreateHappyPets();
    }

    protected void rptHappyPets_ItemBound(object source,RepeaterItemEventArgs e)
    {
        //Label lblCheck = e.Item.FindControl("lblCheck") as Label;
        //HiddenField hldCheck = e.Item.FindControl("hldCheck") as HiddenField;

        //if(lblCheck!=null&&hldCheck!=null)
        //{
        //    if(StringHelper.isNumber_int(hldCheck.Value)==0)
        //    {
        //        lblCheck.Text = "等待审核";
        //    }
        //    else if (StringHelper.isNumber_int(hldCheck.Value) == 1)
        //    {
        //        lblCheck.Text = "审核通过";
        //    }
        //}
    }
}
